<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="https://cdn.jsdelivr.net/npm/vue"></script>
    <style>

    </style>
</head>

<body>
    <div id="app">
    </div>
    <script>
        let arr = [4, 5, 6] // 1.题目 [4, 5, 6] =》 ['4','5','6']
        let arr1 = arr.reduce((prev, current) => {
            prev.push(current + '')
            return prev
        }, [])
        console.log(arr1)
        console.log('---------------------------------------')

        var booksArr = [{
            name: 'Vuejs入门',
            price: 99,
            count: 3
        }, {
            name: 'Vuejs底层',
            price: 89,
            count: 1
        }, {
            name: 'Vuejs从入门到放弃',
            price: 19,
            count: 5
        }, ]

        // 拼串 + 计算总价格
        let arr2 = booksArr.reduce((prev, current) => {
            prev.push(`${current.name},价格:${current.price},数量:${current.count}`)
            return prev
        }, [])
        console.log(arr2)

        let arr3 = booksArr.reduce((prev, current) => {
            return prev + (current.price * current.count)
        }, 0)
        console.log('总价格', arr3)
    </script>
</body>

</html>